home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef __THREADCONTEXT__
- #define __THREADCONTEXT__
-
- class TException;
-
- #include <Threads.h>
- #include "MWException.h"
-
- pascal OSErr ThreadCreateNotifyHandler(ThreadID createdThread, long threadCreateRefcon);
- pascal OSErr ThreadCreateHandler(ThreadEntryProcPtr threadEntry, void *threadParam, long handlerRefCon, ThreadID *threadMade);
-
- class TThreadContext
- {
- private:
- static long fCreatedThreads;
- static long fSleepingThreads;
-
- public:
- TThreadContext(long threadCreateRefcon);
- ~TThreadContext() { --fCreatedThreads; if(fSleeping) --fSleepingThreads; }
-
- void SwapIn(ThreadID);
- void SwapOut(ThreadID);
- void DisposeContext(ThreadID);
-
- long ThreadCreateRefcon() const { return fThreadCreateRefcon; }
-
- static long TotalThreads() { return fCreatedThreads; }
- static long SleepingThreads() { return fSleepingThreads; }
- static long ActiveThreads() { return TotalThreads() - SleepingThreads(); }
-
- private:
-
- ExceptionState fExceptionStack;
- char fCatchBuffer[CATCH_BUFSIZE]; // buffer for thrown object
-
- #if 0
- #if __MWERKS__
- void* fLocalDestructorChain;
- #endif
- TException* fExceptionStack;
- #endif
-
- const long fThreadCreateRefcon;
- Boolean fSleeping;
- };
-
- #endif
-